package com.lin.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

/**
 * 常用注解
 * RequestParam:将客户端的name属性值和方法参数列表的参数名对应起来,默认必须传name属性值得参数
 * RequestBody:获取请求体的数据
 * PathVariable:restful风格
 */
@Controller
@RequestMapping("/anno")
public class AnnoController {
    @RequestMapping("/testAnnoParam")
    public String testAnnoParam(@RequestParam(name = "name") String username){
        return "success";
    }
    /*RequestBody:获取请求体的数据*/
    @RequestMapping("/testRequestBody")
    public String testRequestBody(@RequestBody String body){
        System.out.println("执行了...");
        System.out.println(body);
        return "success";
    }

    @RequestMapping("/testpathVariable/{id}")
    public String testpathVariable(@PathVariable(name = "id") String id){
        System.out.println("执行了...");
        System.out.println(id);
        return "success";
    }


}
